package org.softmed.persistence;

import java.util.Collection;
import java.util.List;
import org.softmed.reflection.utils.FieldInfo;

public interface PersistenceManager {

	public void connect() throws Throwable;

	public void close() throws Throwable;

	public void commit() throws Throwable;

	public void rollback() throws Throwable;

	public void store(Object obj) throws Throwable;

	public void delete(Object obj) throws Throwable;

	public List getListFromField(Class type, String id, String fieldName)
			throws Throwable;

	public List getPaginatedListFromFieldRound(Class type, String id,
			String fieldName, int initialIndex, int size) throws Throwable;

	public List getPaginatedListFromField(Class type, String id,
			String fieldName, int initialIndex, int finalIndex)
			throws Throwable;

	public Object getListItemFromField(Class type, String id, String fieldName,
			int index) throws Throwable;

	public int getListCountFromField(Class type, String id, String fieldName)
			throws Throwable;

	public long count(Class type) throws Exception;

	public Object getById(Class type, String idFieldName, Object id)
			throws Exception;

	public Object getById(Class type, String id) throws Throwable;

	public Object getFieldValue(Class type, String id, String fieldName)
			throws Throwable;

	public long save(Object obj) throws Exception;

	public long getInternalId(Object obj) throws Exception;

	public Object getObjectID(Object obj) throws Throwable;

	public Object getObjectById(long id) throws Throwable;

	public Collection<FieldInfo> getGeneratedFields(Class type)
			throws Throwable;

	public FieldInfo getPrimaryKeyInfo(Class type) throws Throwable;

	public List getObjects(Class type) throws Throwable;

	public List getObjects(Class type, boolean inMemory, int initialIndex,
			int finalIndex) throws Throwable;

}
